package net.ib.mtalk.network.task;

import android.content.Context;
import android.os.Handler;
import net.ib.mntalk.protocol.Common.UUIDMsg;
import net.ib.mntalk.protocol.Common.UserAccessControl;
import net.ib.mntalk.protocol.Session.SetUserAccessControlReq;
import net.ib.mtalk.network.MethodId.Session;
import net.ib.mtalk.network.TcpEnvelope;
import net.ib.mtalk.util.GpbSupport;
import net.ib.mtalk.util.NotifyingAsyncQueryHandler;

public class SetUserAccessControlTask extends AsyncNetTask {
	
	private Context mContext;
	private Handler mUiHandler;
	private NotifyingAsyncQueryHandler mDbHandler;
	private int index, type;
	private int nameAcl, profileImageAcl, genderAcl, birthdayAcl, bioAcl, presenceAcl, statusAcl, locationAcl, moodAcl;

	public SetUserAccessControlTask(Context _context, Handler _uiHandler, int _index, int _type, int _nameAcl, int _profileImageAcl, 
			int _genderAcl, int _birthdayAcl, int _bioAcl, int _presenceAcl, int _statusAcl, int _locationAcl, int _moodAcl) {
		super(_context, _uiHandler);
		mContext = _context;
		mUiHandler = _uiHandler;
		this.index = _index;
		this.type = _type;
		this.nameAcl = _nameAcl; 
		this.profileImageAcl = _profileImageAcl;
		this.genderAcl = _genderAcl; 
		this.birthdayAcl = _birthdayAcl;
		this.bioAcl = _bioAcl;
		this.presenceAcl = _presenceAcl;
		this.statusAcl = _statusAcl;
		this.locationAcl = _locationAcl;
		this.moodAcl = _moodAcl;
	}

	@Override
	protected TcpEnvelope onPreExecute() {
		SetUserAccessControlReq setUserAccessControlReq = new SetUserAccessControlReq();
//		setUserAccessControlReq.setUserUuid(GpbSupport.makeUuidMsg(333, 444));
		setUserAccessControlReq.setProperty(index, type);
		
		UserAccessControl userAccessControl = new UserAccessControl();
		userAccessControl.setNameAcl(nameAcl);
		userAccessControl.setProfileImageAcl(profileImageAcl);
		userAccessControl.setGenderAcl(genderAcl);
		userAccessControl.setBirthdayAcl(birthdayAcl);
		userAccessControl.setBioAcl(bioAcl);
		userAccessControl.setPresenceAcl(presenceAcl);
		userAccessControl.setStatusAcl(statusAcl);
		userAccessControl.setLocationAcl(locationAcl);
		userAccessControl.setMoodAcl(moodAcl);
		setUserAccessControlReq.setAccessControl(userAccessControl);
		
		TcpEnvelope rev = new TcpEnvelope.Builder()
			.setType(TcpEnvelope.REQUEST)
			.setMessage(setUserAccessControlReq)
			.setMethodId(Session.User.SetUserAccessControl)
			.build();
		return rev;
	}

	@Override
	protected void onPostExecute(int resultCode, Object requestObj,
			Object resultObj) {
		// TODO Auto-generated method stub

	}

}
